package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookCoinCashAcctHistory;
import com.pgybook.db.entity.domain.BookCoinCashAcctHistoryEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookCoinCashAcctHistoryMapper {
    int countByExample(BookCoinCashAcctHistoryEx example);

    int deleteByExample(BookCoinCashAcctHistoryEx example);

    @Delete({
            "delete from bookcoincashaccthistory",
            "where COINCASHHISID = #{coincashhisid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long coincashhisid);

    @Insert({
            "insert into bookcoincashaccthistory (CUSTID, TYPE, ",
            "PAYCOMPANYID, ORDERID, ",
            "INSTANCEID, AMOUNT, ",
            "CRTTIME)",
            "values (#{custid,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, ",
            "#{paycompanyid,jdbcType=INTEGER}, #{orderid,jdbcType=BIGINT}, ",
            "#{instanceid,jdbcType=BIGINT}, #{amount,jdbcType=DECIMAL}, ",
            "#{crttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "coincashhisid", before = false, resultType = Long.class)
    int insert(BookCoinCashAcctHistory record);

    int insertSelective(BookCoinCashAcctHistory record);

    List<BookCoinCashAcctHistory> selectByExample(BookCoinCashAcctHistoryEx example);

    @Select({
            "select",
            "COINCASHHISID, CUSTID, TYPE, PAYCOMPANYID, ORDERID, INSTANCEID, AMOUNT, CRTTIME",
            "from bookcoincashaccthistory",
            "where COINCASHHISID = #{coincashhisid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    BookCoinCashAcctHistory selectByPrimaryKey(Long coincashhisid);

    int updateByExampleSelective(@Param("record") BookCoinCashAcctHistory record, @Param("example") BookCoinCashAcctHistoryEx example);

    int updateByExample(@Param("record") BookCoinCashAcctHistory record, @Param("example") BookCoinCashAcctHistoryEx example);

    int updateByPrimaryKeySelective(BookCoinCashAcctHistory record);

    @Update({
            "update bookcoincashaccthistory",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "TYPE = #{type,jdbcType=INTEGER},",
            "PAYCOMPANYID = #{paycompanyid,jdbcType=INTEGER},",
            "ORDERID = #{orderid,jdbcType=BIGINT},",
            "INSTANCEID = #{instanceid,jdbcType=BIGINT},",
            "AMOUNT = #{amount,jdbcType=DECIMAL},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP}",
            "where COINCASHHISID = #{coincashhisid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BookCoinCashAcctHistory record);
}
